<?php $this->load->view('common/head');?>
<form class="form-horizontal" name="add" id="add" action="<?php echo $this->input->server('REQUEST_URI'); ?>" method="post">
  <input type="hidden" name="id" id="id" value="<?=$gxData['id']?>">
  <input type="hidden" name="procId" id="procId" value="<?=$procId?>">
  <input type="hidden" name="projectId" id="projectId" value="<?=$projectId?>">
  <div class="form-group">
    <label class="col-sm-2 control-label" for="mediaType1">媒体类型</label>
    <div class="col-sm-4">
    <select class="form-control" placeholder="" id="mediaType1" name="mediaType1" required>
		<option value="">请选择</option>
    </select>
    <input type="input" class="form-control" name="mediaType1Alias" id="mediaType1Alias" value="<?=$gxData['mediaType1Alias']?>" placeholder="其它媒体类型">
    <select class="form-control" placeholder="" id="mediaType2" name="mediaType2">
		<option value="">请选择</option>
    </select>
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="mediaName">媒体名称</label>
    <div class="col-sm-4">
    <input type="input" class="form-control" required name="mediaName" id="mediaName" value="<?=$gxData['mediaName']?>" placeholder="项目名称">
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="mediaSize">投放规格</label>
    <div class="col-sm-4">
    <select class="form-control" placeholder="" id="mediaSize" name="mediaSize">
		<option value="">请选择</option>
    </select>
    <div class="input-group" id="inputMediaSizeAlias1">
      <div class="input-group-addon">长：</div>
      <input type="text" class="form-control" id="mediaSizeAlias1" name="mediaSizeAlias1" value="<?=$gxData['mediaSizeAlias1']?>" placeholder="">
      <div class="input-group-addon">cm</div>
    </div>
    <div class="input-group" id="inputMediaSizeAlias2">
      <div class="input-group-addon">高：</div>
      <input type="text" class="form-control" id="mediaSizeAlias2" name="mediaSizeAlias2" value="<?=$gxData['mediaSizeAlias2']?>" placeholder="">
      <div class="input-group-addon">cm</div>
    </div>
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="startTime">开始时间</label>
    <div class="col-sm-4">
   	<input type="text" class="form-control" required onFocus="WdatePicker({minDate:'<?=($projectData['isBubao'] || $isSpecialBubao) ? $this->timeUnitModel->getTimeUnitStartDate($procData['timeUnit'], $procData['year']) : date("Y-m-d")?>',maxDate:'#F{$dp.$D(\'endTime\')||\'<?=$this->timeUnitModel->getTimeUnitEndDate($procData['timeUnit'], $procData['year'])?>\'}'})" name="startTime" id="startTime" value="<?=$gxData['startTime']?>" placeholder="开始时间">
	</div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="endTime">结束时间</label>
    <div class="col-sm-4">
    <input type="text" class="form-control" required onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')||\'<?=($projectData['isBubao'] || $isSpecialBubao) ? $this->timeUnitModel->getTimeUnitStartDate($procData['timeUnit'], $procData['year']) : date("Y-m-d")?>\'}',maxDate:'<?=$this->timeUnitModel->getTimeUnitEndDate($procData['timeUnit'], $procData['year'])?>'})" name="endTime" id="endTime" value="<?=$gxData['endTime']?>" placeholder="结束时间">
	</div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="frequency">发布频次</label>
    <div class="col-sm-4">
    <input type="number" class="form-control" min="0" name="frequency" id="frequency" value="<?=$gxData['frequency']?>" placeholder="发布频次">
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="budgetApply">预算费用</label>
    <div class="col-sm-4">
    <input type="number" class="form-control" required min="0" step="0.01" name="budgetApply" id="budgetApply" value="<?=(float)$gxData['budgetApply'] ? $gxData['budgetApply'] : ''?>" placeholder="预算费用">
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label" for="remarks">备注</label>
    <div class="col-sm-4">
    <textarea class="form-control" name="remarks" id="remarks" rows="3"><?=$gxData['remarks']?></textarea>
    </div>
  </div>
  <div class="form-group text-center">
	  <button type="submit" class="btn btn-default btn-primary">保存</button>
	  <button type="button" onclick="closeWindow()" class="btn btn-default btn-primary">取消</button>
	  </div>
</form>
<script type="text/javascript" src="public/js/commonGx.js"></script>
<script type="text/javascript">
$(function(){
  //Init Validation
  initValidation();
  $("#mediaSize").hide();
  $("#inputMediaSizeAlias1").hide();
  $("#inputMediaSizeAlias2").hide();
  mediaType1Display(<?=isset($gxData['mediaType1']) ? $gxData['mediaType1'] : 0?>);
  mediaType2Display(<?=isset($gxData['mediaType1']) ? $gxData['mediaType1'] : 0?>, <?=isset($gxData['mediaType2']) ? $gxData['mediaType2']:0?>);
  mediaSizeDisplay(<?=isset($gxData['mediaType1']) ? $gxData['mediaType1'] : 0?>, <?=isset($gxData['mediaType2']) ? $gxData['mediaType2']:0?>, <?=isset($gxData['mediaSize']) ? $gxData['mediaSize'] : 0?>, <?=isset($gxData['mediaSize']) ? $gxData['mediaSize'] : 0?>);
  $("#mediaType1").change(function(){
    mediaType2Display($("#mediaType1").val());
    mediaSizeDisplay($("#mediaType1").val(), 0, $("#mediaSize").val());
    initValidation();
  });
  $("#mediaType2").change(function(){
    mediaSizeDisplay($("#mediaType1").val(), $("#mediaType2").val());
    initValidation();
  });
  $("#mediaSize").change(function(){
    mediaSizeDisplay($("#mediaType1").val(), $("#mediaType2").val(), $("#mediaSize").val(), this.value);
    initValidation();
  });
});
/**
 * 重启验证
 * @return {[type]} [description]
 */
function initValidation() {
  $('form[name="add"]').find("input,select,textarea").jqBootstrapValidation("destroy");
  $('form[name="add"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
    preventSubmit:false,
    submitSuccess: function (form, event) {
         event.preventDefault();
         ajaxFormSubmit('add');
     },
     submitError: function (form, event, errors) {
       event.preventDefault();
     }
  });
}
</script>
<?php $this->load->view('common/foot');?>